﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Protected关键字
{
    //protected关键字 受保护的，可以在当前类的内部以及该类的子类中访问
    //protected protected protected protected protected protected protected protected protected protected protected protected protected
    public class Prog
    {
        protected string _name;//用protected访问修饰符
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }
    }
        public class A:Prog
        {
            public void a()
            {
                Console.WriteLine(_name);//在子类当中可以访问
            }
        }
        public class B
        {
            public void b()//在没有继承Prog中无法访问。
            {
                Console.WriteLine();
            }
        }
 }
